﻿@model List<LeadMaster.Models.LeadGroups>

<div>
<table class="listtable contactstable" cellspacing="0" cellpadding="0" style="width: 600px;" id="grouplist">
<thead>
    <tr>
    <th class="tableheader" style="width: 200px;">Title</th>
    <th class="tableheader">Display Order</th>
    <th class="tableheader">Questionnaire Order</th>
    <th class="tableheader"></th>
    <th class="tableheader"></th>
    </tr>
</thead>
@foreach (var item in Model)
{
    <tr>
    <td><label class="selectgroupsection" data-groupid="@(item.LeadGroupsID)" style="cursor: pointer; color: #333333;">@item.Title</label></td>
    <td><label>@item.DisplayOrder</label></td>
    <td><label>@item.QuestionOrder</label></td>
    <td><input type="button" value="Questions" class="leadgroups" data-groupid="@(item.LeadGroupsID)" /></td>
    <td><img src="~/Images/delete.ico" style="width: 20px; height: 20px" class="deleteleadgroupquestion" data-deleteleadgroupquestionid="@(item.LeadGroupsID)"/></td>
    </tr>
}
</table>
</div>

<div id="groupquestions">
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $("#groupquestions").dialog(
        {
            autoOpen: false,
            width: 1200,
            open: function () { $(".ui-dialog").css("box-shadow", "#000 5px 5px 5px"); },
            position: ['middle', 20],
            modal: true,
            dialogClass: 'notitle',
            buttons: {
                cancel: function () {
                    $(this).dialog("close");
                }
            }
        });

        $(".leadgroups").click(function () {
            $("#groupquestions").dialog("open");
            $('#groupquestions').html('<div style="text-align: center;"><div><img src="@Url.Content("~/Images/ajaxspinner_large.gif")" alt="Loading..." style="margin: 20px;" /></div><div>Loading...</div></div>');
            var contactURL = '@(Url.Action("ShowGroupQuestions", "LeadBuilder"))/?id=' + $(this).data("groupid");
            $('#groupquestions').load(contactURL);
        });

        $(".selectgroupsection").click(function () {
            $("#EditLeadGroup").dialog("open");
            $('#EditLeadGroup').html('<div style="text-align: center;"><div><img src="@Url.Content("~/Images/ajaxspinner_large.gif")" alt="Loading..." style="margin: 20px;" /></div><div>Loading...</div></div>');
            var contactURL = '@(Url.Action("EditLeadGroup", "LeadBuilder"))/?id=' + $(this).data("groupid");
            $('#EditLeadGroup').load(contactURL);
        });

        $(".deleteleadgroupquestion").click(function () {
            var ans = confirm("Are you sure you wish to delete this section ?")
            if (ans == true) {
                var contactURL = '@(Url.Action("DeleteGroupSectionQuestion", "LeadBuilder"))/?id=' + $(this).data("deleteleadgroupquestionid");
                $('#ShowLeadGroups').load(contactURL);
            }
        });
    });
</script>